<?php

if (!defined('TOBBIVM'))
	header('location:/template/notrepassing.php');
/**
 * This file is part of TobbiVMShop.
 *
 * TobbiVMShop is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TobbiVMShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TobbiVMShop.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * create adminedotorpage
 * get: admin.editor.tpl.php
 * used from admin.page.php
 *
 * @version    $Id$
 * @package    TobbiVM-Shop
 * @copyright  Copyright (C) 2012
 * @author     Norbert Gebert
 * @license    GPL3
 */
$refPage->assign('pageTitel', _('Entry editor'));
// create customer-editor
$datax = $refValidate->testText($_GET['id'], _('Customer-ID'), 1, 10);
db::getInstance()->where('customer_id', $datax);
$customer = db::getInstance()->getOne('customer');

if (db::getInstance()->count <= 0)
{ // No entry...
	message::setErrorRow(_('Customer-entry not found') . ' -> ' . $datax, true);
}
else
{
	$refPage->assign('formStart', 'index2.php?page=' . $page . '&sub=' . $subpage . '&func=0');

	$refPage->assign('id', _('Customer-ID') . ': ');
	$refPage->assign('idx', $customer['customer_id']);

	$refPage->assign('company', _('Company') . ': ');
	$refPage->assign('companyx', $customer['customer_company']);

	$refPage->assign('firstname', _('Firstname') . ': ');
	$refPage->assign('firstnamex', $customer['customer_firstname']);

	$refPage->assign('lastname', _('Lastname') . ': ');
	$refPage->assign('lastnamex', $customer['customer_lastname']);

	$refPage->assign('street', _('Street') . ': ');
	$refPage->assign('streetx', $customer['customer_street']);

	$refPage->assign('zip', _('Zip-Code') . ': ');
	$refPage->assign('zipx', $customer['customer_zip']);

	$refPage->assign('city', _('City') . ': ');
	$refPage->assign('cityx', $customer['customer_city']);


	$refPage->assign('country', _('Country') . ': ');

	db::getInstance()->where('config_key', 'country');
	db::getInstance()->orderBy("config_text", "ASC");
	$customerCountry = db::getInstance()->get('config');

	$countryx = '';
	foreach ($customerCountry as $group)
	{
		$countryx .= '<option value="' . $group['config_text'] . '" ';
		if ($group['config_text'] == $customer['customer_country'])
			$countryx .= 'selected=\'selected\'';

		$countryx .= '>' . $group['config_text'] . '</option>';
	}
	$refPage->assign('countryx', $countryx);

	$refPage->assign('state', _('State') . ': ');
	$refPage->assign('statex', LANGUAGE_NAME);

	$refPage->assign('phone', _('Phone') . ': ');
	$refPage->assign('phonex', $customer['customer_phone']);

	$refPage->assign('fax', _('Fax') . ': ');
	$refPage->assign('faxx', $customer['customer_fax']);

	$refPage->assign('handy', _('Handy') . ': ');
	$refPage->assign('handyx', $customer['customer_handy']);

	$refPage->assign('email', _('Email') . ': ');
	$refPage->assign('emailx', $customer['customer_email']);


	$refPage->assign('level', _('Userlevel') . ': ');

	db::getInstance()->where('config_key', 'customer_group');
	db::getInstance()->orderBy("config_value", "ASC");
	$customerGroup = db::getInstance()->get('config');

	$levelx = '<select size="1" name="levelx" id="levelx">';
	foreach ($customerGroup as $group)
	{
		$levelx .= '<option value="' . $group['config_value'] . '" ';
		if ($group['config_value'] == $customer['customer_level'])
			$levelx .= 'selected=\'selected\' ';

		$levelx .= '>' . $group['config_text'] . '</option>';
	}
	$levelx .= '</select>';
	$refPage->assign('levelx', $levelx);


	$refPage->assign('name', _('Username') . ': ');
	$refPage->assign('namex', $customer['customer_name']);

	$refPage->assign('password', _('Password') . ': ');
	$refPage->assign('passwordx', '****************');

	$refPage->assign('lastonline', _('Lastonline') . ': ');
	$refPage->assign('lastonlinex', $customer['customer_lastonline']);

	$refPage->assign('ip', _('Last IP') . ': ');
	$refPage->assign('ipx', $customer['customer_ip']);

	$refPage->assign('text', _('Info') . ': ');
	$refPage->assign('textx', $customer['customer_info']);

	$refPage->assign('errors', _('Loginerrors') . ': ');
	$refPage->assign('errorsx', $customer['customer_errors']);

	$refPage->assign('active', _('Active') . ': ');
	if ($customer['customer_active'] === '0')
	{
		$refPage->assign('activex', '');
	}
	else
	{
		$refPage->assign('activex', 'checked');
	}

	$refPage->assign('btnSave',
		'<input type="hidden" name="passwordx" value="' . $customer['customer_password'] . '">' .
		'<input type="hidden" name="idxx" value="' . $customer['customer_id'] . '">' .
		'<input type="hidden" name="secureidx" value="' . $customer['customer_secureid'] . '">' .
		'<input type="submit" name="submit" id="save" value="' . _('Save') . '" />');
	$refPage->assign('btnAbort',
		'<input type="submit" name="submit" id="abort" value="' . _('Cancel') . '" />');
	$refPage->assign('btnPassword',
		'<input type="submit" name="submit" id="password" value="' . _('New password') . '" />');

	$refPage->addtpl('content', '/' . $page . '/' . $subpage . '.editor.tpl.php');
	$refPage->assign('scripts',
		'<script type="text/javascript" src="' .
		'module/ckeditor/ckeditor.js"></script>');
}
?>